<template>
  <div class="page-container">
    <SearchPanel @change="handleSearchPanelChange">
      <el-form
        ref="queryForm"
        class="query-more-form"
        size="mini"
        label-width="100px"
        :model="query"
      >
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="许可文件编号">
              <el-input
                v-model="query.number"
                class="search-ipt"
                placeholder="请输入许可文件编号"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="许可文件名称">
              <el-input
                v-model="query.name"
                class="search-ipt"
                placeholder="请输入许可文件名称"
                maxlength="255"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6" class="btn-col">
            <el-button size="mini" class="search-btn" @click="handleSelect">查询</el-button>
          </el-col>
        </el-row>
      </el-form>
    </SearchPanel>
    <div class="table-container">
      <div class="table-tools-panel table-flex-row">
        <el-button class="flush-btn" size="mini" icon="el-icon-refresh" @click="handleSelect"
          >刷新</el-button
        >
        <div>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-set-up"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-share"
          ></el-button>
          <el-button
            class="tools-btn"
            size="mini"
            icon="el-icon-printer"
          ></el-button>
        </div>
      </div>
      <div class="table-list-panel">
        <el-table
          v-loading="tableLoading"
          border
          size="small"
          :data="tableData"
          :height="isShow ? 'calc(100vh - 465px)' : 'calc(100vh - 335px)'"
          style="width: 100%"
        >
          <el-table-column type="selection" width="45" />
          <el-table-column prop="serialNumber" label="序号" show-overflow-tooltip />
          <el-table-column prop="name" label="许可文件名称" show-overflow-tooltip />
          <el-table-column prop="number" label="许可文件编号" show-overflow-tooltip />
          <el-table-column prop="validPeriodStart" label="有效期自" show-overflow-tooltip />
          <el-table-column prop="validPeriodEnd" label="有效期至" show-overflow-tooltip />
          <el-table-column prop="agencyName" label="许可机关" show-overflow-tooltip />
          <el-table-column prop="content" label="许可内容" show-overflow-tooltip />
          <el-table-column prop="content" label="详情" show-overflow-tooltip />
        </el-table>
      </div>
      <div class="pagination-panel">
        <Pagination
          :total="query.total"
          :page.sync="query.pageNum"
          :limit.sync="query.pageSize"
          @pagination="initData"
        />
      </div>
    </div>
  </div>
</template>

<script>
import SearchPanel from "@/components/SearchPanel";
import Pagination from "@/components/Pagination";
import { getPage } from '@/api/performanceSupport/license'
export default {
  name: "CaseDealDispatch",
  components: {
    SearchPanel,
    Pagination,
  },
  data() {
    return {
      query: {
        name: null,
        number: null,
        total: 0,
        pageNum: 1,
        pageSize: 10,
      },
      tableLoading: false,
      tableData: [],
      isShow: true,
    };
  },
  created() {
    this.initData()
  },
  methods: {
    handleSearchPanelChange(flag) {
      this.isShow = flag;
    },
   initData() {
      this.handleSelect()
    },
    handleSelect() {
      this.tableLoading = true
      getPage(this.query).then(res => {
        this.tableData = res.rows
        this.query.total = res.total
        this.tableLoading = false
      }).catch(() => {
        this.tableLoading = false
      })
    },
  },
};
</script>

<style lang="scss" scoped>
</style>